﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Senthil.Mobile.WhereAmI
{
    public interface INotifier
    {
        void Notify(string[] users, NotificationMessage message);
    }

    public class NotificationMessage
    {
        public string OwnerName { get; set; }
        public string LocationName {get;set;}
        public string LocationGroupName {get;set;}

        public string DestinationLocationGroupName { get; set; }
        public TimeSpan DestinationTimeSpan { get;set;}
        public DateTime DestinationTime { get; set; }

        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
                return true;

            NotificationMessage msg = obj as NotificationMessage;

            if (Object.ReferenceEquals(msg, null))
                return false;

            return msg.OwnerName == OwnerName && msg.LocationGroupName == LocationGroupName &&
                msg.LocationName == LocationName && msg.DestinationLocationGroupName == DestinationLocationGroupName &&
                msg.DestinationTimeSpan == DestinationTimeSpan;
        }

        public override string ToString()
        {
            if (DestinationTimeSpan == TimeSpan.Zero)
            {
                return string.Format("{0} is at {1}", OwnerName,
                    LocationGroupName != null ? LocationGroupName + "(" + LocationName + ")" : LocationName);
            }
            else
            {
                return string.Format("{0} is at {1} and will reach {2} at {3}",
                    OwnerName,
                    LocationGroupName != null ? LocationGroupName + "(" + LocationName + ")" : LocationName,
                    DestinationLocationGroupName,
                    DestinationTime.ToString());
            }
        }
    }
}
